<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2547：[Ctsc2002]玩具兵</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2002]玩具兵</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Ctsc2002]玩具兵</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Ctsc2002]玩具兵                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p class="MsoPlainText" style="margin: 0cm 0cm 0pt; text-indent: 24pt"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">小明的爸爸给他买了一盒玩具兵，其中有</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"> K</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个步兵，</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">K</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个骑兵和一个天兵，个个高大威猛，形象逼真。盒子里还有一个</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">M*N</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">棋盘，每个格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">(i,j)</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">都有一个高度</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">H<sub>ij</sub></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">，并且大得足以容纳所有的玩具兵。小明把所有的玩具兵都放到棋盘上去，突然想到了一种很有趣的玩法：任意挑选</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">T</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个不同的格子，并给每个格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">规定一个重要值</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">R<sub>i&shy;&shy;</sub></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">，游戏的目标就是每次沿东南西北之一的方向把一个玩具兵移动到其相邻的格子中（但不能移动到棋盘外面去），最终使得每个挑选出的格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">上恰好有</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">R<sub>i</sub></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个玩具兵。小明希望所有的玩具兵都在某个选定的格子中，因此他总是使选出的</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">T</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个格子的重要值之和等于玩具兵的个数。为了增加难度，小明给玩具兵们的移动方式做了一些规定：</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt"><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 'Times New Roman'">●<span lang="EN-US"><span style="mso-spacerun: yes">&nbsp; </span></span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">步兵只会往高处爬，因此如果两个格子</span></font><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">和</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">相邻，当且仅当格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">的高度小于或等于</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">，步兵才可以从</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">移动到</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><span style="mso-list: Ignore"><font face="宋体">●</font><span style="font: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">骑兵只会往低处跳，因此如果两个格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">和</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">相邻，当且仅当格子</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">的高度大于或等于</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">，骑兵才可以从</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">A</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">移动到</font></span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt">B</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><span style="mso-list: Ignore"><font face="宋体">●</font><span style="font: 7pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">天兵技术全面，移动不受任何限制。</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可是没玩几次，小明就发现这个</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">游戏太难了，他常常玩了好半天也达不到目的。于是，他设计了一种&ldquo;超能力&rdquo;，</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每使用一次超能力的时候，虽然不能移动任何一个玩具兵，但可对它们进行任意多次交换操作，每次交换两个玩具兵。等这次超能力使用完后又可和平常一样继续移动这些玩具兵。借助强大的超能力，这个游戏是容易玩通的，但是怎样才能让使用超能力的次数最少呢？</span><span lang="EN-US" style="font-size: 12pt; font-family: &quot;Times New Roman&quot;; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><b style="mso-bidi-font-weight: normal"><span lang="EN-US"><o:p><font face="宋体" size="3">&nbsp;</font></o:p></span></b></p>
<p></p></p><hr/><h3>输入格式</h3><p><p class="MsoPlainText" align="left" style="margin: 0cm 0cm 0pt; text-align: left"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">第一行包含四个整数：</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">M,N,K,T (2&lt;=M,N&lt;=100, 1&lt;=K&lt;=50, 1&lt;=T&lt;=2K+1)</span><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><o:p></o:p></span></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><font face="宋体"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">第二行包括</span></font><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">2K+1</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">个数对</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">(x<sub>i</sub>,y<sub>i</sub>)</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">，代表各个玩具兵的初始位置。前</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">K</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">个代表</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">步</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">兵，接下来的</span></font><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">K</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">个代表</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">骑兵</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">，最后一个代表</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">天</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">兵。<span lang="EN-US"><o:p></o:p></span></span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><font face="宋体"><span lang="EN-US" style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt">第三行包含</span></font><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">T</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">个三元组</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">(x<sub>i</sub>,y<sub>i</sub>,r<sub>i</sub>)</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">，第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">组代表第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">个目标格的位置和重要值。<span lang="EN-US"><o:p></o:p></span></font></span></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"><span style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">以下</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">M</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">行，每行</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">N</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个整数。其中第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">i</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">行第</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">j</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个数为即格子的高度</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">H<sub>ij</sub></span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">。高度是不超过</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">100</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">的正整数，注意：不同玩具兵的初始位置可能相同。输入数据保证无错，选定的</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">T</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><font face="宋体">个格子的重要值之和保证等于</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">2K+1</span><font face="宋体"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</span></font></p>
<p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体"><span lang="EN-US"><o:p></o:p></span></font></span></p></p><hr/><h3>输出格式</h3><p><p class="MsoPlainText" style="margin: 0cm 0cm 0pt"><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">仅包含一行，即使用超能力的最小次数</font></span><span lang="EN-US" style="font-size: 12pt; font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt">T</span><span style="font-size: 12pt; mso-bidi-font-size: 10.0pt"><font face="宋体">。</font></span></p></p><hr/><h3>样例输入</h3><pre>4  6  2  5
1  1     1  5     4  1     4  5     3  3
1  2  1    2  6  1    3  2  1    3  6  1    4  3  1
3  2  6  1  3  5
2  1  7  4  4  6
2  3  1  4  3  4
4  3  4  3  2  3
</pre><hr/><h3>样例输出</h3><pre>1</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>鸣谢刘汝佳先生授权使用</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2547" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2547" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>